import java.util.ArrayList;
import java.util.Iterator;

/**
 * The type Al set.
 *
 * E for Data type of element
 *
 * @author Yihan Wang
 * @date 24/06/09
 * @param <E> the type parameter
 */
public class ALSet<E> implements Iterable<E> {
    private ArrayList<E> eArrayList;

    /**
     * Instantiates a new Al set.
     */
    public ALSet() {
        eArrayList = new ArrayList<>();
    }

    /**
     * Add object.
     *
     * @param e the e
     * @return the boolean
     */
    public boolean add(E e) {
        if (eArrayList.contains(e)) {
            return false;
        } else {
            eArrayList.add(e);
            return true;
        }
    }

    /**
     * Remove object.
     *
     * @param e the e
     * @return the boolean
     */
    public boolean remove(E e) {
        if (eArrayList.contains(e)) {
            eArrayList.remove(e);
            return true;
        } else {
            return false;
        }
    }

    /**
     * Contains object.
     *
     * @param e the e
     * @return the boolean
     */
    public boolean contains(E e) {
        return eArrayList.contains(e);
    }

    /**
     * Clear.
     */
    public void clear() {
        eArrayList.clear();
    }

    /**
     * Size int.
     *
     * @return the int
     */
    public int size(){return eArrayList.size();}

    public String toString() {
        return eArrayList.toString();
    }

    public Iterator<E> iterator() {
        return eArrayList.iterator();
    }
}
